package com.upc.cajabancos.util;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Util {
	
	static public Date getFinDia(Date theDate) {
	
		Date result = null;

		if (theDate != null) {
			GregorianCalendar calendar = new GregorianCalendar();
		    calendar.setTime(theDate);
		    calendar.set( Calendar.HOUR_OF_DAY ,calendar.getMaximum(Calendar.HOUR_OF_DAY) ) ;
		    calendar.set( Calendar.MINUTE ,calendar.getMaximum(Calendar.MINUTE) ) ;
		    calendar.set( Calendar.SECOND ,calendar.getMaximum(Calendar.SECOND) ) ;

		    result =  calendar.getTime();
		 }
		    return result ;
		}

	static public Date getComienzoDia(Date theDate) {
		
		Date result = null;

		if (theDate != null) {
			GregorianCalendar calendar = new GregorianCalendar();
		    calendar.setTime(theDate);
		    calendar.set( Calendar.HOUR_OF_DAY ,calendar.getMinimum(Calendar.HOUR_OF_DAY) ) ;
		    calendar.set( Calendar.MINUTE ,calendar.getMinimum(Calendar.MINUTE) ) ;
		    calendar.set( Calendar.SECOND ,calendar.getMinimum(Calendar.SECOND) ) ;

		    calendar.set( Calendar.MILLISECOND ,calendar.getMinimum(Calendar.MILLISECOND ) ) ;


		    result =  calendar.getTime();
		}
		return result ;
	}

}
